getProviderRatingsByAgentId
getProviderRatingsByAgentId
This method retrieves rating information for a provider (agent), with optional inclusion of user comments and detailed rating statistics.
-
Identify the Provider
- Search for the provider associated with the given
agentId. - If no provider is found, return
null(end of process).
- Search for the provider associated with the given
-
Prepare Basic Rating Summary
-
Extract basic details from the provider:
- Agent ID
- Average Rating
- Overall Rating Count
-
Initialize a response object with these values.
-
-
(Optional) Include Comments
- Triggered only if
includeCommentsistrue. - Retrieve recent rating comments for the agent (up to a specified limit).
- Filter the comments to ensure they belong to the current agent.
- Attach the filtered comments to the response.
- Triggered only if
-
(Optional) Generate Deep Statistics
-
Triggered only if
deepStatsistrue. -
Count the number of ratings falling into these categories:
- 5-star
- 4-star (between 4.0 and 4.99)
- 3-star (between 3.0 and 3.99)
- 2-star (between 2.0 and 2.99)
- 1-star (between 1.0 and 1.99)
-
Attach this breakdown as a separate object in the response.
-
-
Return Final Output
-
Return the structured response object containing:
- Basic rating info
- (Optional) Comments
- (Optional) Deep statistics
-